/**
 * Created by dell on 2017/5/4.
 */
import {ChangeDetectionStrategy, ViewEncapsulation, Component, Renderer, OnInit} from "@angular/core";
import * as globals from '@core/globals/globals.service';
import {EventsService} from "@core/events/events.service";
import {ToolbarService} from "@shared/components/toolbar/toolbar.service";
import {Router} from "@angular/router";

@Component({
  selector: 'seed-toolbar-nav',
  template: `
    <div class="seed-toolbar-nav unfold">
      <a
        [routerLink]="['/']"
        [routerLinkActive]="'current'"
        [routerLinkActiveOptions]="{exact: true}"
        (click)="hideNav($event)"
      >
        首页
      </a>
      <a
        [routerLink]="['/match']"
        [routerLinkActive]="'current'"
        (click)="hideNav()"
      >
        赛事
      </a>
      <a
        [routerLink]="['/sharing']"
        [routerLinkActive]="'current'"
        (click)="hideNav()"
      >
        分享
      </a>
      <a
        [routerLink]="['/community']"
        [routerLinkActive]="'current'"
        (click)="hideNav()"
      >
        社区
      </a>
      <!--<a-->
        <!--[routerLink]="['/home']"-->
        <!--[routerLinkActive]="'current'"-->
        <!--(click)="hideNav()"-->
      <!--&gt;-->
        <!--资讯-->
      <!--</a>-->
 <!---->
   <!---->
<!--      <a
        [routerLink]="['/video']"
        [routerLinkActive]="'current'"
        (click)="hideNav()"
      >
        视频
      </a>-->
      <!--<a-->
      <!--[routerLink]="['/goods/list']"-->
      <!--[routerLinkActive]="'current'"-->
      <!--(click)="hideNav('V18')"-->
      <!--&gt;-->
      <!--票务-->
      <!--</a>-->
      <!--<a-->
      <!--[routerLink]="['/crowd']"-->
      <!--[routerLinkActive]="'current'"-->
      <!--(click)="hideNav()"-->
      <!--&gt;-->
      <!--众筹-->
      <!--</a>-->

      <a
        [routerLink]="['/mine']"
        [routerLinkActive]="'current'"
        (click)="hideNav()"
      >
        我的
      </a>
    </div>`,
  changeDetection: ChangeDetectionStrategy.OnPush,
  encapsulation: ViewEncapsulation.None,
})
export class ToolbarNavComponent implements OnInit {

  constructor(public toolBarService: ToolbarService,
              public events: EventsService,
              private renderer: Renderer,
              public router: Router) {
  }

  hideNav(param?) {
    if (param === 'V18') {
      this.router.navigate(['/goods/list/V18']);
    }

    globals.isUnfold.next(false);
    document.body.classList.toggle('unfold');

  }

  progressBarHandle(states: boolean = true) {
    if (states) {
      this.events.publish('progressbar:show');
    } else {
      this.events.publish('progressbar:hide');
    }
  }

  ngOnInit() {
    this.toolBarService.showNav();
  }
}
